package com.example.supernote.ui.trash


import androidx.compose.material3.SnackbarHostState
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import kotlinx.coroutines.launch

@Composable
fun TrashRoute(
    trashViewModel: TrashViewModel,
    isExpandedScreen: Boolean,
    openDrawer: () -> Unit,
    snackbarHostState: SnackbarHostState = remember { SnackbarHostState() }
) {
    val coroutineScope = rememberCoroutineScope()
    val uiState: TrashUiState by trashViewModel.uiState.collectAsStateWithLifecycle()
    TrashScreen(
        uiState = uiState,
        search = { trashViewModel.search(it) },
        completelyDelete = { coroutineScope.launch { trashViewModel.completelyDelete(it) } },
        recovery = { coroutineScope.launch { trashViewModel.recovery(it) } },
        isExpandedScreen = isExpandedScreen,
        openDrawer = openDrawer,
        snackbarHostState = snackbarHostState
    )
}
